Ext.define("XTFrame.view.ruiyuan.RecruitmentManager",{
	extend: 'Ext.grid.Panel',
	alias: 'widget.ruiyuanRecruitmentManager',
	region: 'center',
	frame: true,
	autoScroll: true,
	enableKeyNav: true,
	columns: [ Ext.create("Ext.grid.RowNumberer", {width:32}),
				{width: 360, text: '招聘职位', dataIndex: 'job_name', sortable: true}, 
				{width: 120, text: '工作地点', dataIndex: 'address'}, 
				{width: 120, text: '招聘人数', dataIndex: 'num'}, 
				{width: 120, text: '状态', dataIndex: 'state'} ],
	tbar: [ {xtype: 'button', text: '添加', action: 'gridAdd', iconCls: 'icon-add'},
			{xtype: 'button', text: '删除', action: 'gridDelete', iconCls: 'icon-delete'},
			{xtype: 'button', text: '修改', action: 'gridEdit', iconCls: 'icon-edit'},
			{xtype: 'button', text: '查询', action: 'gridSearch', iconCls: 'icon-search'} ],
	initComponent: function(){
		var me = this;
		Ext.create('XTFrame.store.ruiyuan.Recruitment', {storeId: 'ruiyuan_recruitment',
			listeners:{
				beforeload: function(store, options){
					var new_params = {
						iFunc: ajaxUtil.FUNC_PAGING,
						strData: Ext.JSON.encode({totalSqlObject: {sqlID: "ruiyuan_recruitment_1", parameters: {job_name: me.job_name}},
							querySqlObject: {sqlID: "ruiyuan_recruitment_2", parameters: {start: options.start, limit: options.limit, job_name: me.job_name}}})
					};
			        Ext.apply(store.proxy.extraParams, new_params);
			    },
			    load: function(store, records, successful){
			    	if(successful){
			    		ajaxUtil.isLogin(store.proxy.reader.jsonData);
			    	}
			    }
			}
		});
		Ext.apply(this,{
			store: Ext.data.StoreManager.lookup('ruiyuan_recruitment'),
			selType: 'checkboxmodel',
			multiSelect: true,
			job_name: '',
			editWindow: 'XTFrame.view.ruiyuan.RecruitmentEditWindow',
			editWinId: 'ruiyuanRecruitmentEditWindow',
			searchWindow: 'XTFrame.view.ruiyuan.RecruitmentSearchWindow',
			searchWinId: 'ruiyuanRecruitmentSearchWindow',
			addSql: 'ruiyuan_recruitment_4',
			addValues: ['job_id', 'job_name', 'address', 'num', 'content', 'state'],
			editSql: 'ruiyuan_recruitment_5',
			editValues: ['job_id', 'job_name', 'address', 'num', 'content', 'state'],
			deleteSql: 'ruiyuan_recruitment_3',
			deleteValues: ['job_id'],
			searchValues: ['job_name'],
			dockedItems: [{
				xtype: 'pagingtoolbar',
				dock: 'bottom',
				displayInfo: true,
				store: Ext.data.StoreManager.lookup('ruiyuan_recruitment')
			}]
		});
		this.callParent(arguments);
	}
});